package com.example.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class InternalPage extends AnyPage {

	@FindBy(xpath = "//li[1]/a")
	public WebElement menuHomeLink;

	@FindBy(xpath = "//li[2]/a")
	public WebElement menuMyProfileLink;

	@FindBy(xpath = "//li[3]/a")
	public WebElement menuUserManagement;

	@FindBy(xpath = "//li[4]/a")
	public WebElement menuLogoutLink;

	public boolean isOnThisPage() {
		return menuLogoutLink.isDisplayed();
	}

	public void logOut() {
		menuLogoutLink.click();
		waiter().until(alertIsPresent()).accept();
	}

	@Override
	void tryToOpen() {
		MyPageFactory.getPage(driver, LoginPage.class)
				.loginWithValidCredentials("admin", "admimn");
	}

	public UserManagementPage gotomenuUserManagement() {
		menuUserManagement.click();
		return MyPageFactory.getPage(driver, UserManagementPage.class);
	}

}
